<?php error_reporting(0) ;
ini_set("display_errors", 0 );
?>
<div id="listaResponsavelCompleta">

    <div id="container" >
        <table width="793">
<tr>
                <td width="447" align="left" id="addResponsavel">
                    <a href="#">
                        <img alt="" src="<?php echo base_url() . 'assets/images/responsavel.jpg' ?>" border="0" title="Add Responsavel" onclick="cadastrarResponsavel('<?= $alunoId; ?>')" width="30" height="30"/>                    
                    </a>Novo Respons&aacute;vel
                </td>
        <td width="334"><div id="div_voltar_resp" align="right" style="display: none"><a href="#">
                        <img alt="" src="<?php echo base_url() . 'assets/images/voltar.gif' ?>" border="0" title="Voltar" onclick="voltarResponsavel('<?= $alunoId; ?>')" width="30" height="30"/>
        </a>Voltar</div></td>
          </tr>
        </table>
<br />
        <div id="bodyResponsavel">
        <?php

            if(sizeof($responsavelList->getResult()) > 0){
        ?>
        <fieldset style="width:auto;">
        <legend style="size:auto; font-weight:bold; color:#333333">Dados do Respons&aacute;vel</legend>
        <br />
            <table cellpadding="0" cellspacing="1" border="0" width="790" id="ds_responsavel" >
<thead class="titulo" style="color: #FFFFFF" >
                    <tr style="text-transform: uppercase;" >

                        <th width="57">Nome</th>
                        <th width="122">Parentesco</th>
                        <th width="141">Tel. Residencial</th>
                        <th width="111">Tel. Celular</th>
                        <th width="102">Tel. Trabalho</th>
                      <th colspan="2"></th>
                        
                    </tr>
                </thead>
                <tbody>

                    <?php
                    unset($value);
                    foreach ($responsavelList->getResult() as $value) {
                        
                        $parentesco = $this->em->find('models\parentesco',$value->getParentescoCod());

                        $queryFone = $this->em->createQuery('SELECT t FROM models\telefone t WHERE t.responsavelCod = ?1');
                        $queryFone->setParameter(1, $value->getResponsavelCod());
                        
                        unset($telefone);
                        foreach ($queryFone->getResult() as $telefone) {
                            unset($foneFixo);
                            unset($foneCelular);
                            unset($foneTrabalho);
                            if($telefone->getTelefoneTipo() == 1){

                                $foneFixo = $telefone->getTelefoneNumero();

                            } else if($telefone->getTelefoneTipo() == 0){

                                $foneCelular = $telefone->getTelefoneNumero();

                            } else {
                                $foneTrabalho = $telefone->getTelefoneNumero();
                            }

                        }


                    ?>

                    <tr style="background-color:#FFFFFF" id="tr_<?php echo $value->getResponsavelCod(); ?>" class="ui-corner-top">

                        <td><div align="center" id="respNome_<?php echo $value->getResponsavelCod(); ?>"><?php echo utf8_encode(@$value->getResponsavelNome()); ?></div></td>
                            <td><div align="center" id="respParentesco_<?php echo $value->getResponsavelCod(); ?>"><?php echo utf8_encode(@$parentesco->getParentescoDescricao()); ?></div></td>
                            <td><div align="center" id="respFoneRes_<?php echo $value->getResponsavelCod(); ?>"><?php echo @$foneFixo; ?></div></td>
                            <td><div align="center" id="respCelular_<?php echo $value->getResponsavelCod(); ?>"><?php echo @$foneCelular; ?></div></td>
                            <td><div align="center" id="respFoneTrabalho_<?php echo $value->getResponsavelCod(); ?>"><?php echo @$foneTrabalho; ?></div></td>
                            <td width="105">
  <div align="center">
                                    <a href="#" id="lnkview">
                                        <img alt="" src="<?php echo base_url() . 'assets/images/ico_view.png' ?>" border="0" title="Visualizar" onclick="detalharResponsavel('<?= $value->getResponsavelCod() ?>')" width="20" height="20"/>
                                    </a>
                                </div>
                      </td>
                            <td width="66">
                  <div align="center">
                                    <a href="#" id="lnkdelete">
                                        <img alt="" src="<?php echo base_url() . 'assets/images/excluir.png' ?>" border="0" title="Excluir" onclick="excluirResponsavel('<?php echo $value->getResponsavelCod(); ?>')" disabled />
                                    </a>
                                </div>
                      </td>
                  </tr>
                         
                    <?php  }  ?>

                </tbody>


            </table>
            <br />
</fieldset>
<?php } ?>
            </div>
        <br />
        <div id="formPcpResponsavel"></div>
        <div class="spacer"></div>
    
    </div>
</div>
